home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / hard / misc / CheckMem.lha / checkmemblock.a < prev    next >
Text File  |  1994-12-11  |  1KB  |  66 lines

  1. ; check 32 bytes of memory starting at a0.
  2. ; returns in d0 the erroneous bits set
  3. ; this routine disables interrupts and may thus affect timing critical programs
  4. ; on a 7MHz 68000, interrupts are disabled for approximately 200 microseconds
  5. ; BOOL __asm CheckMemBlock( register __a0 address );
  6.  
  7.     INCLUDE "exec/funcdef.i"
  8.     INCLUDE "exec/exec_lib.i"
  9.  
  10.     xdef _CheckMemBlock
  11.     
  12.     section text,code
  13.  
  14. _CheckMemBlock:
  15.     movem.l    d1-d4/a1/a2/a6,-(sp)
  16.     move.l    4,a6
  17.     moveq.l    #0,d0
  18.     lea    _CheckMemBlock(pc),a1
  19.     lea    end(pc),a2
  20.     cmpa.l    a0,a2
  21.     bmi    cont            ; block starts higher than end of routine
  22.     movea.l    a0,a2
  23.     adda.l    #32,a2
  24.     cmpa.l    a2,a1
  25.     bmi    exit            ; block and routine overlap.. assumed memory good
  26.  
  27. cont:
  28.     moveq.l    #7,d2
  29.     jsr    _LVODisable(a6)        ; appr 1400 cycles with interrupts disabled
  30. loop:
  31.     move.l    (a0),d1
  32.  
  33.     moveq.l #0,d3            ; check 00000000000000000000000000000000
  34.     move.l    d3,(a0)
  35.     move.l    (a0),d4
  36.     eor.l    d4,d3
  37.     or.l    d3,d0
  38.  
  39.     moveq.l    #-1,d3            ; check 11111111111111111111111111111111
  40.     move.l    d3,(a0)
  41.     move.l    (a0),d4
  42.     eor.l    d4,d3
  43.     or.l    d3,d0
  44.  
  45.     move.l    #$55555555,d3        ; check 01010101010101010101010101010101
  46.     move.l    d3,(a0)
  47.     move.l    (a0),d4
  48.     eor.l    d4,d3
  49.     or.l    d3,d0
  50.  
  51.     move.l    #$aaaaaaaa,d3        ; check 10101010101010101010101010101010
  52.     move.l    d3,(a0)
  53.     move.l    (a0),d4
  54.     eor.l    d4,d3
  55.     or.l    d3,d0
  56.  
  57.     move.l    d1,(a0)+
  58.     dbf    d2,loop
  59.  
  60.     jsr    _LVOEnable(a6)
  61. exit:
  62.     movem.l    (sp)+,d1-d4/a1/a2/a6
  63.     rts
  64. end:
  65.     end
  66.